package com.zhuozhengsoft.pageoffice6springboot2back.controller.insertSeal;

import com.zhuozhengsoft.pageoffice.FileSaver;
import com.zhuozhengsoft.pageoffice.OpenModeType;
import com.zhuozhengsoft.pageoffice.PageOfficeCtrl;
import com.zhuozhengsoft.pageoffice6springboot2back.util.GetDirPathUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping(value = "/InsertSeal/Word")
public class WordInsertSealController {
    //获取doc目录的磁盘路径
    private final String dir = GetDirPathUtil.getDirPath() + "/static/doc/";

    public WordInsertSealController() throws IOException {
    }

    @RequestMapping(value = "/AddSeal/Word1")
    public String showWord1(HttpServletRequest request) {
        PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);
        //打开文档
        poCtrl.webOpen("/doc/InsertSeal/Word/AddSeal1/word1.docx", OpenModeType.docNormalEdit, "张三");
        return poCtrl.getHtml();
    }


    @RequestMapping(value = "/AddSeal/Word2")
    public String showWord2(HttpServletRequest request) {
        PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);
        //打开文档
        poCtrl.webOpen("/doc/InsertSeal/Word/AddSeal2/word2.docx", OpenModeType.docNormalEdit, "张三");
        return poCtrl.getHtml();
    }

    @RequestMapping(value = "/AddSeal/Word3")
    public String showWord3(HttpServletRequest request) {
        PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);
        //打开文档
        poCtrl.webOpen("/doc/InsertSeal/Word/AddSeal3/word3.docx", OpenModeType.docNormalEdit, "张三");
        return poCtrl.getHtml();
    }
    @RequestMapping(value = "/AddSeal/Word4")
    public String showWord4(HttpServletRequest request) {
        PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);
        //打开文档
        poCtrl.webOpen("/doc/InsertSeal/Word/AddSeal4/word4.docx", OpenModeType.docNormalEdit, "张三");
        return poCtrl.getHtml();
    }
    @RequestMapping(value = "/AddSeal/Word5")
    public String showWord5(HttpServletRequest request) {
        PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);
        //打开文档
        poCtrl.webOpen("/doc/InsertSeal/Word/AddSeal5/test.docx", OpenModeType.docNormalEdit, "张三");
        return poCtrl.getHtml();
    }
    @RequestMapping(value = "/AddSeal/Word6")
    public String showWord6(HttpServletRequest request) {
        PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);
        //打开文档
        poCtrl.webOpen("/doc/InsertSeal/Word/AddSeal6/test.docx", OpenModeType.docNormalEdit, "张三");
        return poCtrl.getHtml();
    }
    @RequestMapping(value = "/AddSeal/Word7")
    public String showWord7(HttpServletRequest request) {
        PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);
        //打开文档
        poCtrl.webOpen("/doc/InsertSeal/Word/AddSeal7/test.docx", OpenModeType.docNormalEdit, "张三");
        return poCtrl.getHtml();
    }

    @RequestMapping(value = "/AddSeal/Word8")
    public String showWord8(HttpServletRequest request) {
        PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);
        poCtrl.webOpen("/doc/InsertSeal/Word/AddSeal8/word8.docx", OpenModeType.docNormalEdit, "张三");
        return poCtrl.getHtml();
    }
    @RequestMapping(value = "/AddSeal/Word9")
    public String showWord9(HttpServletRequest request) {
        PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);
        //打开文档
        poCtrl.webOpen("/doc/InsertSeal/Word/AddSeal9/word9.docx", OpenModeType.docNormalEdit, "张三");
        return poCtrl.getHtml();
    }

    @RequestMapping(value = "/DeleteSeal/Word")
    public String DeleteSeal(HttpServletRequest request) {
        PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);
        //打开文档
        poCtrl.webOpen("/doc/InsertSeal/Word/DeleteSeal/test.docx", OpenModeType.docNormalEdit, "张三");
        return poCtrl.getHtml();
    }

    @RequestMapping(value = "/AddSign/Word1")
    public String AddSign_Word1(HttpServletRequest request) {
        PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);
        //打开文档
        poCtrl.webOpen("/doc/InsertSeal/Word/AddSign1/word1.docx", OpenModeType.docNormalEdit, "张三");
        return poCtrl.getHtml();
    }


    @RequestMapping(value = "/AddSign/Word2")
    public String AddSign_Word2(HttpServletRequest request) {
        PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);
        //打开文档
        poCtrl.webOpen("/doc/InsertSeal/Word/AddSign2/test.docx", OpenModeType.docNormalEdit, "张三");
        return poCtrl.getHtml();
    }

    @RequestMapping(value = "/AddSign/Word3")
    public String AddSign_Word3(HttpServletRequest request) {
        PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);
        //打开文档
        poCtrl.webOpen("/doc/InsertSeal/Word/AddSign3/test.docx", OpenModeType.docNormalEdit, "张三");
        return poCtrl.getHtml();
    }
    @RequestMapping(value = "/AddSign/Word4")
    public String AddSign_Word4(HttpServletRequest request) {
        PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);
        //打开文档
        poCtrl.webOpen("/doc/InsertSeal/Word/AddSign4/test.docx", OpenModeType.docNormalEdit, "张三");
        return poCtrl.getHtml();
    }

    @RequestMapping(value = "/AddSign/Word5")
    public String AddSign_Word5(HttpServletRequest request) {
        PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);
        //打开文档
        poCtrl.webOpen("/doc/InsertSeal/Word/AddSign5/word2.docx", OpenModeType.docNormalEdit, "张三");
        return poCtrl.getHtml();
    }


    @RequestMapping("/AddSeal/save")
    public void save(HttpServletRequest request, HttpServletResponse response,String savePath) {
        FileSaver fs = new FileSaver(request, response);
        fs.saveToFile(dir + savePath + fs.getFileName());
        fs.close();
    }

    @RequestMapping("/AddSign/save")
    public void save2(HttpServletRequest request, HttpServletResponse response,String savePath) {
        FileSaver fs = new FileSaver(request, response);
        fs.saveToFile(dir + savePath + fs.getFileName());
        fs.close();
    }

}
